package cn.dg.manager.order.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import cn.dg.manager.common.dao.impl.BaseDaoImpl;
import cn.dg.manager.common.entity.GoodsComboboxBean;
import cn.dg.manager.order.dao.OrderDetailDao;
import cn.dg.manager.order.entity.OrderDetailResultBean;
import cn.dg.manager.order.entity.OrderDetailVO;

@Repository("orderDetailDao")
public class OrderDetailDaoImpl extends BaseDaoImpl implements OrderDetailDao {

	public static final String ORDER_DETAIL_SQL_PACKAGE = OrderDetailDao.class.getName().concat(".");
	
	/**
	 * 订单详情信息
	 */
	public List<OrderDetailResultBean> getOrderDetailInfo(Map<String, Object> params) {
		return this.sqlSessionTemplate.selectList(ORDER_DETAIL_SQL_PACKAGE.concat("getOrderDetailInfo"), params);
	}

	/**
	 * 订单详情商品下拉框
	 */
	public List<GoodsComboboxBean> getGoodsComboboxList() {
		return this.sqlSessionTemplate.selectList(ORDER_DETAIL_SQL_PACKAGE.concat("getGoodsComboboxList"));
	}


	/**
	 * 批量插入订单详细信息
	 */
	public int insertOrderDetailList(List<OrderDetailVO> orderDetailVOList) {
        return (int)this.sqlSessionTemplate.insert(ORDER_DETAIL_SQL_PACKAGE.concat("insertOrderDetailList"), orderDetailVOList);
	}

	/**
	 * 根据订单号删除订单详情数据
	 * 
	 */
	public long delOrderDetailInfoByOrderIDList(List<String> orderIDList) {
		return (int)this.sqlSessionTemplate.delete(ORDER_DETAIL_SQL_PACKAGE.concat("delOrderDetailInfoByOrderIDList"), orderIDList);
	}

	/**
	 *  根据订单ID获取订单详情信息
	 *  
	 */
	public List<OrderDetailVO> getOrderDetailEditInfo(String orderId) {
		Map<String, Object> cond = new HashMap<String, Object>();
		cond.put("orderId", orderId);
		return this.sqlSessionTemplate.selectList(ORDER_DETAIL_SQL_PACKAGE.concat("getOrderDetailEditInfo"), cond);
	}
}
